import { h, Component } from 'preact';
import TabContext from './TabContext';
import classNames from 'classnames';

class Panel extends Component {

	constructor(props) {
		super(props);
		this.tab = props.tab
		this.state = {
			active: ''
		};
	}

	render({ title,key,children,...other },state) {
		return (
			<TabContext.Consumer>
				{({ active,onChange }) => {
					// return <div className={active===this.tab?'active':'hidden'}>{children}</div>;
					return <div className={classNames({'active':active===this.tab,'hidden':active!==this.tab})}>{children}</div>;
				}}
			</TabContext.Consumer>
		);
	}
}

Panel.propTypes = {

};

Panel.defaultProps = {
	defaultActive: 1,
	active: 1
};
 
export default Panel;
